const update = () => {
  const hash = window.location.hash || '#posts'
  const mainElement = document.querySelector('.main')
  mainElement.innerHTML = ''
  if (hash === '#posts') {
      import(/* webpackChunkName: 'posts' */'./posts/posts').then(({ default: posts }) => {
          mainElement.appendChild(posts())
      })
  } else if (hash === '#album') {
      import(/* webpackChunkName: 'album' */'./album/album').then(({ default: album }) => {
          mainElement.appendChild(album())
      })
  }
}

window.addEventListener('hashchange', update)
update()